<?php
/**
 * cms后台文章添加管理页
 * author wang
 * mail:970633164@qq.com
 */

define("PHP_IN", true);
require "../include/init.php";
require "checklogin.php";
require ROOT_PATH."cms/smart_connection.php";

if (isset($_POST['dosubmit'])) {
    $title = $_POST['title'];
    $isdisplay = intval($_POST['isdisplay']);
    $content = isset($_POST['editorValue']) ? $_POST['editorValue'] : "";
    $addtime = time();
    if ($title == "" || $content == "") {
        alert("请填写完整的文章内容");
        exit;
    }
    $sql = "INSERT INTO article (title,content,addtime,isdisplay) VALUES ('$title','$content','$addtime','$isdisplay')";
    $result = $db->query($sql);
    if ($result) {
        alert("添加成功", "article_list.php");
    } else {
        alert("添加失败");
    }
}

$smarty->display("article_add.tpl");
$db->close();
?>
